<template>
	<!-- 当mescroll-body写在子组件时,父页面需引入mescroll-comp.js的mixins -->
	<mescroll-body ref="mescrollRef" top="50" @init="mescrollInit" @down="downCallback" @up="upCallback">
		<!-- 数据列表 -->
		<good-list :list="goods"></good-list>
	</mescroll-body>
</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  import mRequest from "@/api/home"
	import goodList from './good-list/good-list.vue'
	import hccmStore from "@/common/hccm-store.js"
	export default {
		mixins: [MescrollMixin], // 使用mixin
    components:{goodList},
		props:{
			hospId:{
				type: String,
			}
		},
		data() {
			return {
				goods: [],
				userInfo: hccmStore.getUser(),
			}
		},
		methods: {
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			upCallback(page) {
				console.log('hospId',this.hospId)
				//联网加载数据
        let params = {
          patientMobile: hccmStore.getUserPhone(),
          hospId: hccmStore.getUserHospId(),
          currentPage: page.num,
          pageSize: page.size,
        }
				if(this.hospId !==''){
					params.hospId =  this.hospId
				}
				
        mRequest.getOrder(params).then(
          res => {
							this.mescroll.endSuccess(res.responseData.total)
							if(page.num == 1) this.goods = []; //如果是第一页需手动制空列表
							this.goods=this.goods.concat(res.responseData.data); //追加新数据
							this.mescroll.endBySize(this.goods.length, Number(res.responseData.total)+10); //
						// }
          },
          error => {
           this.mescroll.endErr();
          }
        )
			}
		}
	}
</script>
